﻿// Copyright (c) Vitaly Kamiansky. All rights reserved. 
// See License.txt in the project root.

using System;
using System.ComponentModel;

namespace Property.Workers
{
    public abstract class Worker : IDisposable
    {
        public abstract bool IsBusy { get; }

        public abstract void RunWorkerAsync();

        public event DoWorkEventHandler DoWork;

        protected virtual void OnDoWork(DoWorkEventArgs e)
        {
            if (DoWork != null)
                DoWork(this, e);
        }

        public event RunWorkerCompletedEventHandler RunWorkerCompleted;

        protected virtual void OnRunWorkerCompleted(RunWorkerCompletedEventArgs e)
        {
            if (RunWorkerCompleted != null)
                RunWorkerCompleted(this, e);
        }

        public virtual void Dispose() { }
    }
}
